//
//  PublicTool.h
//  BSOrange
//
//  Created by kenshin on 14-9-1.
//  Copyright (c) 2014年 BazzarEntertainment. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "IDMPhotoBrowser.h"

@class MBProgressHUD;

@interface PublicTool : NSObject



/**
 *  图片裁减成圆角
 *
 *  @param image  原始图片
 *  @param bounds 裁减后尺寸
 *
 *  @return 才叫后的圆角图片
 */
+ (UIImage *)roundImage:(UIImage *)image bounds:(CGRect)bounds;
+ (void)roundImage:(UIImage *)image bounds:(CGRect)bounds block:(void (^)(UIImage *image))block;

+ (void)showHudAlertWithTitle:(NSString *)title inView:(UIView *)view andShowTime:(float)time;
//展示HUD加载等待框
+ (MBProgressHUD *)showWaitHudWithTitleInWindow:(NSString *)title;
+ (MBProgressHUD *)showWaitHudWithTitle:(NSString *)title inView:(UIView *)tmpView;
+ (void)showNetWorkErrorInView:(UIView *)view;
+ (void)showMsg:(NSString *)msg;


+ (void)showTitle:(NSString *)title msg:(NSString *)msg;
+ (void)showTitle:(NSString *)title msg:(NSString *)msg offsetY:(CGFloat)offsetY;

/**
 *  错误消息提示
 *
 *  @param title 标题
 *  @param msg   消息
 
 注意！！ 如果同时存在标题和消息，只显示消息
 */
+ (void)showError:(NSString *)title msg:(NSString *)msg;
+ (void)showError:(NSString *)title msg:(NSString *)msg offsetY:(CGFloat)offsetY;

/**
 *  统计字符串长度（同新浪微博,ASCII和Unicode混合）
 *
 *  @return 长度
 */
+ (NSInteger)unicodeLengthOfString:(NSString *)text;


+ (NSString *)getNowTimeStamp;
+ (NSString *)currentDateTime;
+ (NSString *)dateTimeYMD:(int)seconds;
+ (NSString *)dateTimeYMD_CH:(int)seconds;
+ (NSString *)dateTimeYMDHMS:(int)seconds;
+ (NSDate *)dateFromString:(NSString *)dateString;


+ (NSString *)getUniqueString;
+ (void)showFadeAnimation:(UIView *)view;

/**
 *  添加目录为iCloud备份忽略路径，Document里非用户明确生成&|大量不定期数据生成的路径需要如此添加为iCloud忽略路径
 *
 *  @param URL 文件路径
 *
 *  @return 成功/失败
 */
+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;

/*
 *以中心点为基准放大或缩小frame
 *@param frame 原frame
 *@param times 放大倍数
 */

+(CGRect)amplifyFrame:(CGRect)frame times:(CGFloat)times;




+ (void)label:(UILabel *)label setMiniFontSize:(CGFloat)fMiniSize forNumberOfLines:(NSInteger)iLines;

+ (void)cancelPerformRequestAndNotification:(UIViewController *)viewCtrl;

#pragma mark - 时间

+ (NSString *)relativeDateStringForTimeinterval:(long long)timeinterval;
+ (NSString *)relativeDateStringForDate:(NSDate *)date;

#pragma mark - 加解密

+ (NSString *)md5StringForString:(NSString *)string;
+ (NSString *)md5StringForData:(NSData *)data;

#pragma mark - 视频播放

+ (void)showVideoPlayer:(NSString *)videoURLString;

#pragma mark - IDPhotoBrowser

/**
 展示大图浏览器
 
 @param photos           被展示的图片集合:IDMPhoto数组, 每个IDMPhoto可以是本地文件 + (IDMPhoto *)photoWithFilePath:(NSString *)path;; 也可以是网络图片: + (IDMPhoto *)photoWithURL:(NSURL *)url;
 @param currentIndex     当前展示的图片索引
 @param animatedFromView @optional 从animatedFromView开始做平滑的放大动画
 @param animatedImage    @optional 被放大的animatedImage
 */
+ (void)showPhotoGallaryWithPhotos:(NSArray<IDMPhoto *> *)photos startAtIndex:(NSInteger)currentIndex animatedFromView:(UIView *)animatedFromView animatedImage:(UIImage *)animatedImage;

/**
 展示大图浏览器
 
 @param photoURLs        被展示的图片集合:图片url字符串数组
 @param currentPhotoURL  当前展示的图片url
 @param animatedFromView @optional 从animatedFromView开始做平滑的放大动画
 @param animatedImage    @optional 被放大的animatedImage
 */
+ (void)showPhotoGallaryWithPhotoURLs:(NSArray *)photoURLs startAtURL:(NSString*)currentPhotoURL animatedFromView:(UIView *)animatedFromView animatedImage:(UIImage *)animatedImage;

/**
 展示大图浏览器
 
 @param filePaths        被展示的图片集合:图片本地文件路径字符串数组
 @param currentFilePath  当前展示的图片path
 @param animatedFromView @optional 从animatedFromView开始做平滑的放大动画
 @param animatedImage    @optional 被放大的animatedImage
 */
+ (void)showPhotoGallaryWithPhotoFilePaths:(NSArray *)filePaths startAtFilePath:(NSString*)currentFilePath animatedFromView:(UIView *)animatedFromView animatedImage:(UIImage *)animatedImage;

@end
